package com.crois.barrier.admin;

import com.zhimydou.zdf.wf.cache.CacheTemplate;
import com.zhimydou.zdf.wf.web.WfApplication;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;
import javax.annotation.PostConstruct;
import java.util.Arrays;
import java.util.List;

@MapperScan({"com.crois.barrier.admin.mapper"})
@ComponentScan(basePackages = {"com.zhimydou.cloud.auth.fegin.client","com.zhimydou.zdf.wf.web.controller","com.crois.barrier.admin"})
@Import({CacheTemplate.class})
@EnableFeignClients(basePackages = {"com.zhimydou.cloud.service","com.zhimydou.cloud.auth.fegin.client"})
@EnableDiscoveryClient
@SpringBootApplication
public class BarrierAdmin {

    private static final Logger log = LoggerFactory.getLogger(BarrierAdmin.class);

    private final Environment env;

    public BarrierAdmin(Environment env) {

        this.env = env;

    }

    public static void main(String[] args) {
        WfApplication.bootstrap(args,BarrierAdmin.class);
    }

    @PostConstruct
    public void initApplication(){
        List<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
        if (activeProfiles.contains("dev")&&activeProfiles.contains("prod")){
            log.error("错误配置！不能同时使用'dev'和'prod'");
        }
    }

}
